package com.hyper_yang._03_designpatterns.principles.demo3.next;

/**
 * projectName: com.hyper_yang._03_designpatterns.principles.demo3.next
 *
 * @author: sakiko
 * time: 2025/9/26 20:27
 * description: 计算机类
 * 依赖倒置原则 【面向接口编程，而不是面向实现类】
 */
public class Computer {
    private HardDisk hardDisk;
    private CPU cpu;
    private Memory memory;

    public HardDisk getHardDisk() {
        return hardDisk;
    }

    public void setHardDisk(HardDisk hardDisk) {
        this.hardDisk = hardDisk;
    }

    public CPU getCpu() {
        return cpu;
    }

    public void setCpu(CPU cpu) {
        this.cpu = cpu;
    }

    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }

    public void run() {
        System.out.println("Computer.run");
        System.out.println("hardDisk.get() = " + hardDisk.get());
        cpu.run();
        memory.save();
    }
}
